package model

import (
	"fmt"
	"gitee.com/jinmingzhi/kit/rand_code"
	"gitee.com/jinmingzhi/kit/rdb"
	"time"
)

type PayList struct {
	ID         uint32   `db:"id"`
	UID        uint32   `db:"uid"`
	PayNum     string   `db:"pay_num"` // 账单号
	SchoolTime string   `db:"school_time"`
	BatchName  string   `db:"batch_name"` // 报考批次
	Amount     float32  `db:"amount"`
	Status     bool     `db:"status"` //是否已支付
	CreateTime rdb.Time `db:"create_time"`
}

type Pay struct {
	ID         uint32   `db:"id"`
	UID        uint32   `db:"uid"`
	PayNum     string   `db:"pay_num"` // 账单号
	SchoolTime string   `db:"school_time"`
	BatchID    uint32   `db:"batch_id"` // 报考批次id
	Amount     float32  `db:"amount"`
	Status     bool     `db:"status"` //是否已支付
	CreateTime rdb.Time `db:"create_time"`
}

func NewPay(uid, batch_id uint32, school_time string) *Pay {
	return &Pay{
		UID:        uid,
		PayNum:     generate(),
		SchoolTime: school_time,
		BatchID:    batch_id,
		Amount:     35,
		Status:     false,
		CreateTime: rdb.FromTime(time.Now()),
	}
}

func generate() (pay_num string) {
	return fmt.Sprintf("pay-%d-%s", time.Now().Unix(), rand_code.RandStringBytesMaskImprSrcUnsafe(4))
}
